<?php

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

require '../com.swiss.mooh.dao.impl/DescriptionDaoImpl.php';
require '../com.swiss.mooh.service/DescriptionServiceImpl.php';


$dispatcher = new DescriptionDaoImpl();
$descriptionService = new DescriptionServiceImpl($dispatcher);


switch ($_POST['type']) {
    //Create New Description
    case 0:
        $menuSelect = $_POST['menuSelectID'];
        $descName = $_POST['descName'];
        $productDescription = $_POST['descDesc'];
        $pageType = $_POST['page_type'];
        $result = $descriptionService->createNewDescription(uniqid(), $descName, $productDescription, date('Y-m-d h:i:s a', time()), $menuSelect, $pageType);
        echo $result;
        break;
    case 1:
        $descID = $_POST['descID'];
        $descName = $_POST['descName'];
        $productDescription = $_POST['descDesc'];
        $pageType = $_POST['page_type'];
        $result = $descriptionService->updateDescription($descID, $descName, $productDescription, $pageType);
        echo $result;
        break;
}